package com.ly.algorithm.leetcode.BST;


public class TreeNode {
       int val;
       TreeNode left;
       TreeNode right;
       TreeNode(int x) { val = x; }

       public void preOrder(TreeNode treeNode) {
       	    System.out.println(treeNode.val);
       	    if(treeNode.left!=null)
				preOrder(treeNode.left);
       	    if(treeNode.right!=null)
				preOrder(treeNode.right);
       }

       //  1
	   // 2  3
	   //4
       public static void main(String[] args) {
       	    TreeNode treeNode = new TreeNode(1);
			treeNode.left = new TreeNode(2);
			treeNode.right = new TreeNode(3);
			treeNode.left.left = new TreeNode(4);
			treeNode.left.right = new TreeNode(5);
			treeNode.preOrder(treeNode);
       }
}